﻿@inherits OperationDialogBase<ResourceFunctionEditOption, bool>
<Row Style="padding-right:5px;">
    <AntDesign.Col>
        <Table DataSource="@_functionDtos"
               TItem="FunctionDto"
               PageSize="_functionDtos.Count()"
               Loading="@_loading"
               Context="model"
               Size=@TableSize.Small
               HidePagination="true"
               Bordered="true"
               SelectedRows="@_selectedFunctionDtos"
               SelectedRowsChanged="SelectedRowsChanged"
               ScrollY="75Vh"
               Style="max-height:75Vh;"
               EnableVirtualization>
            <TitleTemplate>
                @if (this.Options.Type == 0)
                {
                    <Row>
                        <AntDesign.Col Span="8">
                            <ResourceAuthorize ResourceKey="system_manager_resource_function_delete_selected">
                                <Button Type="@ButtonType.Primary" Icon="delete" Danger OnClick="OnFunctionDeletesClick">
                                    @localizer[SharedLocalResource.DeleteSelected]
                                </Button>
                            </ResourceAuthorize>
                        </AntDesign.Col>
                        <AntDesign.Col Span="16" Style="text-align:right">
                            <Space>
                                <ResourceAuthorize ResourceKey="system_manager_resource_function_add_page_show">
                                    <SpaceItem>
                                        <Button Type="@ButtonType.Primary" Icon="plus" OnClick="x => OnShowFunctionAddPageClick(this.Options.Resource)">
                                            @localizer[SharedLocalResource.Select]
                                        </Button>
                                    </SpaceItem>
                                </ResourceAuthorize>
                                <ResourceAuthorize ResourceKey="system_manager_resource_function_download_seed_data">
                                    <SpaceItem>
                                        <Button Icon="download" Type="@ButtonType.Primary" Size="@ClientConstant.OperationButtonSize" OnClick="()=>OnDownloadSeedDataClick(this.Options.Resource)">
                                            @localizer[SharedLocalResource.SeedData]
                                        </Button>
                                    </SpaceItem>
                                </ResourceAuthorize>
                            </Space>
                        </AntDesign.Col>
                    </Row>
                }
                else if (this.Options.Type == 1)
                {
                    <Row>

                        <AntDesign.Col Span="24">
                            <Space>
                                <ResourceAuthorize ResourceKey="system_manager_resource_function_binding">
                                    <SpaceItem>
                                        <Button Type="@ButtonType.Primary" Icon="check" OnClick="x => OnFunctionAddClick()" Loading="_bindLoading">
                                            @localizer["Binding"]
                                        </Button>
                                    </SpaceItem>
                                </ResourceAuthorize>
                            </Space>
                        </AntDesign.Col>
                    </Row>
                }
            </TitleTemplate>
            <ColumnDefinitions>
                <ResourceAuthorize ResourceKey="system_manager_resource_function_delete_selected">
                    <Selection Key="@(model.Path+"_"+model.Method)" Width="50" />
                </ResourceAuthorize>
                <Column TData="string" @bind-Field="@model.Group" Width="150" Sortable="false" Filterable OnFilter="((value,name)=>name.Equals(value))" />
                <Column TData="string" @bind-Field="@model.Service" Width="150" Sortable="false" Filterable OnFilter="((value,name)=>name.Equals(value))" />
                <Column @bind-Field="@model.Summary" Width="150" Sortable="false" Ellipsis />
                <Column @bind-Field="@model.Description" Width="200" Sortable="false" Ellipsis />
                <Column @bind-Field="@model.Path" Width="150" Sortable="false" Ellipsis />
                <Column @bind-Field="@model.Method" Width="100" Sortable="false" Filters="TableFiltersConstants.FunctionMethodFilters">
                    <TagPro Text="@EnumHelper.GetEnumDescription(model.Method)"></TagPro>
                </Column>
                <Column @bind-Field="@model.EnableAudit" Width="100" Sortable="false" Filterable>
                    <TagYesNo Yes="@model.EnableAudit"></TagYesNo>
                </Column>
            </ColumnDefinitions>
        </Table>
    </AntDesign.Col>
</Row>
